package com.water.wfo.news.controller;

import com.water.wfo.component.api.entity.response.BasicResponse;
import com.water.wfo.news.api.NewsApi;
import com.water.wfo.sys.pojo.entity.UserEntity;
import com.water.wfo.user.ability.UserAbility;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
public class NewsController implements NewsApi {

    @Autowired(required = false)
    private UserAbility userAbilityImpl;
    @Override
    public BasicResponse<String> queryNews(@RequestBody Map<String, String> map) {

        return new BasicResponse().buildSuccess("启动成功！");
    }

    @Override
    public BasicResponse<List<UserEntity>> queryAll(Map<String, String> map) {
        UserEntity user = new UserEntity();
        user.setLoginName(map.get("loginName"));
        List<UserEntity>  list =userAbilityImpl.queryAll(user);
        BasicResponse<List<UserEntity>> basicResponse = new BasicResponse<>();
        return basicResponse.buildSuccess(list);
    }
}
